package com.pzh.mall.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.pzh.mall.constant.OrderStatus;
import com.pzh.mall.dao.OrderActionMapper;
import com.pzh.mall.model.Order;
import com.pzh.mall.model.OrderAction;
import com.pzh.mall.service.IOrderActionService;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Administrator
 */
@Service
public class OrderActionServiceImpl implements IOrderActionService {
    @Resource
    private OrderActionMapper orderActionMapper;

    @Override
    public void save(Order order, String action, String userId) {
        this.save(order, action, userId, null);
    }

    @Override
    public void save(Order order, String action, String userId, String remark) {
        OrderAction orderAction = new OrderAction();
        orderAction.setActionUser(userId);
        orderAction.setLogTime(System.currentTimeMillis());
        orderAction.setOrderId(order.getOrderId());
        orderAction.setOrderStatus(order.getOrderStatus());
        orderAction.setPayStatus(order.getPayStatus());
        orderAction.setShippingStatus(order.getShippingStatus());
        orderAction.setStatusDesc(action);
        orderAction.setActionNote(remark);
        orderActionMapper.insert(orderAction);
    }

    @Override
    public List<OrderAction> queryByOrderId(Integer orderId) {
        return orderActionMapper.queryByOrderId(orderId);
    }
}
